<template>
	<div class="admin_all">
		<admin_top></admin_top>
    <div style="padding: 0 20px;">
      <div class="flex">
      	<el-input v-model="name" placeholder="店铺名"></el-input>
      	<el-input v-model="id_card" placeholder="身份证号"></el-input>
      	<el-input v-model="mobile" placeholder="手机号"></el-input>
        <el-input v-model="sign" placeholder="短信签名"></el-input>
      	<el-button size="mini" type="danger" @click="getlist">搜索</el-button>
      </div>


      <div class="zu" v-if="all != ''">
        <el-button type="text" @click="kai(all)">添加飞鸽签名</el-button>
        <el-button type="text" @click="chakan(all.user_id)">查看飞鸽签名</el-button>
      	<div class="tit">商家信息</div>
      	<div class="con">
      		<div class="flex">
            <div class="lli">店铺名称:{{all.name}} <i class="el-icon-edit-outline" style="color: #409eff; cursor: pointer; font-size: 16px;" @click="gai(1)"></i></div>
      			<div class="lli">联系电话:{{all.mobile}} <i  style="color: #409eff;  cursor: pointer; font-size: 16px;" class="el-icon-edit-outline"  @click="gai(2)"></i></div>
      			<div class="lli">密码:暂无  <span style="margin-left: 20px;">重置</span><i  style="color: #409eff;  cursor: pointer; font-size: 16px;" class="el-icon-refresh"  @click="gai(3)"></i></div>
            <div class="lli">SHARE_ID:{{all.user_id}}</div>

            <div class="lli" style="cursor: pointer;" @click="gai(4)" v-if="all.status == 0">点击开启店铺</div>
            <div class="lli" style="cursor: pointer;" @click="gai(5)" v-if="all.status != 0">点击关闭店铺</div>

            <!--    'name_warn' => -12, 非法账户名
                    'stop_use' => 10, 停用
                    'to_identify' => 5, 待验证
                    'deleted' => -1 删除的
            0 启用 -->

      		</div>
      	</div>
      </div>
      <div class="zu" v-if="all != ''">
      	<div class="tit">店铺余额</div>
      	<div class="con">
      		<div class="flex">

      			<div class="lli">账户余额:{{all.balance}}</div>
      			<div class="lli">短信余额:{{all.message_recharge}}</div>
      		</div>
          <div class="flex" style="align-items: center;">
            <div>小螺号信息：{{all.site_domain}}</div>
            <el-button type="text" style="margin-left: 20px;" @click="shanchu()">删除</el-button>
          </div>
      	</div>
      </div>
      <div class="zu" v-if="all != ''">
      	<div class="tit">已配置接口</div>
      	<div class="con">
      		<el-table :data="all.upstreamChannels" style="text-align: center;" align="center" border >
            <el-table-column label="接口ID">
              <template slot-scope="scope">
                <span>{{ scope.row.id }}</span>
              </template>
            </el-table-column>
      		  <el-table-column label="接口名称">
      		    <template slot-scope="scope">
      		      <span>{{ scope.row.c_name }}</span>
      		    </template>
      		  </el-table-column>
      		  <el-table-column label="提单地址">
      		    <template slot-scope="scope">
      		      <div v-for="(item,index) in scope.row.submit_url" :key="index">{{item}}</div>
      		    </template>
      		  </el-table-column>


      		  <el-table-column label="用户端名称">
      		    <template slot-scope="scope">
      		      <span>{{ scope.row.user_defined_name }}</span>
      		    </template>
      		  </el-table-column>
            <el-table-column label="添加时间">
              <template slot-scope="scope">
                <span>{{ scope.row.created_at }}</span>
              </template>
            </el-table-column>
      		  <el-table-column label="操作">
      		    <template slot-scope="scope">
      		      <!-- <el-button v-if="scope.row.status==0" type="text" @click="shenhe(1,scope.row.id)">审核通过</el-button>
      		      <el-button v-if="scope.row.status==0" type="text" @click="shenhe(2,scope.row.id)">审核拒绝</el-button> -->


      		    </template>
      		  </el-table-column>
      		</el-table>
      	</div>
      </div>
    </div>

    <el-dialog title="添加飞鸽签名" :visible.sync="log" width="600px" :close-on-click-modal="false"
      :close-on-press-escape="false">

      <el-input style="width: 500px; margin-bottom: 20px;" placeholder="请输入签名名称" v-model="feigeall.name"></el-input>
      <el-input style="width: 500px;" placeholder="请输入签名ID" v-model="feigeall.sign"></el-input>

      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="log = false">关闭</el-button>
        <el-button type="primary" @click="tianjia">添加</el-button>
      </span>
    </el-dialog>

    <el-dialog title="修改飞鸽签名ID" :visible.sync="log3" width="600px" :close-on-click-modal="false"
      :close-on-press-escape="false">

      <el-input style="width: 500px;" placeholder="请输入签名ID" v-model="feigeall2.sign"></el-input>

      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="log = false">关闭</el-button>
        <el-button type="primary" @click="tianjia2">修改</el-button>
      </span>
    </el-dialog>

    <el-dialog title="查看飞鸽签名" :visible.sync="log2" width="1200px" :close-on-click-modal="false"
      :close-on-press-escape="false">

      <el-table :data="tableData2" style="text-align: center;" align="center" border >

        <el-table-column label="签名">
          <template slot-scope="scope">
            <span>{{ scope.row.name }}</span>
          </template>
        </el-table-column>
        <el-table-column label="签名ID">
          <template slot-scope="scope">
            <span>{{ scope.row.sign }}</span>
          </template>
        </el-table-column>


        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button type="text" @click="xiugai(scope.row)">修改</el-button>
            <el-button type="text" @click="shanchu2(scope.row)">删除</el-button>



          </template>
        </el-table-column>
      </el-table>

      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="log2 = false">关闭</el-button>
      </span>
    </el-dialog>

	</div>
</template>

<script>
  import admin_top from './top.vue';
	import axios from "axios";
	export default {
    components:{
      admin_top
    },
		name: "admin_all",
		data() {
			return {
				name: "",
				id_card:'',
				mobile:'',
				all: "",
        sign:"",

        feigeall: {
          shop_id: "",
          name: "",
          sign: ""
        },
        log: false,
        log2: false,
        tableData2: "",
        feigeall2:{
          id:"",
          sign: "",
          shop_id: "",
        },
        log3:false
			};
		},
		created() {

		},
		methods: {
      shanchu2: function(item, val) {
        this.$confirm('确定删除吗', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(() => {
          axios.get('/api/plan-market/admin/outer-store/sign/feige/delete?id=' + item.id)
            .then(response => {
              if (response.data.msg.code == 0) {
                this.$message.success('操作成功');
                this.chakan(item.shop_id)
                this.log = false
              } else {
                this.$message.error(response.data.msg.info);
              }
            })
        })
      },
      xiugai: function(item) {
        this.feigeall2 = {
          id: item.id,
          shop_id: item.shop_id,
          sign: item.sign
        }
        this.log3 = true
      },
      tianjia2:function(){
        axios.post('/api/plan-market/admin/outer-store/sign/feige/update', this.feigeall2)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message.success('操作成功');
              this.log3 = false
              this.chakan(this.feigeall2.shop_id)
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      chakan: function(id) {
        axios.get('/api/plan-market/admin/outer-store/sign/feige/list?shop_id=' + id)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.tableData2 = response.data.data
              this.log2 = true
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      tianjia: function() {
        axios.post('/api/plan-market/admin/outer-store/sign/feige/add', this.feigeall)
          .then(response => {
            if (response.data.msg.code == 0) {
              this.$message.success('操作成功');
              this.log = false
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
      },
      kai: function(item) {
        this.feigeall = {
          shop_id: item.user_id,
          name: "",
          sign: ""
        }
        this.log = true
      },
      shanchu:function(){
        this.$confirm('确定要删除吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          axios.post(`/api/plan-market/admin/person-site/del`,{id:this.all.person_site_id})
          	.then(response => {
          		if (response.data.msg.code == 0) {
          			this.$message.success('删除成功');
                this.getlist()
          		} else {
          			this.$message.error(response.data.msg.info);
          		}
          	});
        })
      },
      gai:function(who){
        if(who == 1){
          this.$prompt('请输入新的店铺名', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
          }).then(({ value }) => {
            axios.post(`/api/plan-market/admin/shop/update/name`,{user_id:this.all.user_id,name:value})
            	.then(response => {
            		if (response.data.msg.code == 0) {
            			this.$message.success('修改成功');
            		} else {
            			this.$message.error(response.data.msg.info);
            		}
            	});
          })

        }
        if(who == 2){
          this.$prompt('请输入新的手机号', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
          }).then(({ value }) => {
            axios.post(`/api/plan-market/admin/shop/update/mobile`,{user_id:this.all.user_id,mobile:value})
            	.then(response => {
            		if (response.data.msg.code == 0) {
            			this.$message.success('修改成功');
            		} else {
            			this.$message.error(response.data.msg.info);
            		}
            	});
          })
        }
        if(who == 3){
          this.$confirm('是否重置密码为000000?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            axios.post(`/api/plan-market/admin/shop/reset/password`,{user_id:this.all.user_id})
            	.then(response => {
            		if (response.data.msg.code == 0) {
            			this.$message.success('重置成功');
            		} else {
            			this.$message.error(response.data.msg.info);
            		}
            	});
          })
        }
        if(who == 4){
          this.$confirm('要开启店铺吗', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
          }).then(({ value }) => {
            axios.post(`/api/plan-market/admin/shop/update/status`,{user_id:this.all.user_id,status:0})
            	.then(response => {
            		if (response.data.msg.code == 0) {
            			this.$message.success('已开启');
            		} else {
            			this.$message.error(response.data.msg.info);
            		}
            	});
          })

        }
        if(who == 5){
          this.$confirm('要关闭店铺吗', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
          }).then(({ value }) => {
            axios.post(`/api/plan-market/admin/shop/update/status`,{user_id:this.all.user_id,status:10})
            	.then(response => {
            		if (response.data.msg.code == 0) {
            			this.$message.success('已关闭');
            		} else {
            			this.$message.error(response.data.msg.info);
            		}
            	});
          })

        }

      },
			go: function(url) {
				this.$router.push(url)
			},
			getlist: function() {

				axios.get(`/api/plan-market/admin/shop/info?name=${this.name}&id_card=${this.id_card}&mobile=${this.mobile}&sign=${this.sign}`)
					.then(response => {
						if (response.data.msg.code == 0) {
							this.all = response.data.data
						} else {
							this.$message.error(response.data.msg.info);
						}
					});
			}
		}
	};
</script>

<style lang="scss" scoped>
	.admin_all {
		background: #EAEAEA;
		min-height: 100vh;
		padding: 0px;

		.logo {
			height: 30px;
		}

		.el-input {
			width: 180px;
			margin-right: 10px;
		}

		.flex {
			display: flex;
		}



		.zu {
			margin-top: 20px;

			.tit {
				background: #ccc;
				line-height: 45px;
				padding-left: 20px;
			}

			.con {
				background: #FFFFFF;
				padding: 20px;
				line-height: 30px;
				font-size: 14px;
			}

			.lli {
				margin-right: 30px;
				color: #666;
			}
		}
	}
</style>
